package com.zoho.model_project.service;

import com.alibaba.fastjson.JSONObject;
import com.zoho.model_project.utils.CrmApiUtil;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class TestServiceImpl implements TestService {

    CrmApiUtil crmApiUtil;

    public TestServiceImpl(CrmApiUtil crmApiUtil) {
        this.crmApiUtil = crmApiUtil;
    }


    @Override
    public void test() {

        List<String> allModuleName = crmApiUtil.getAllModuleName();
        //System.out.println("allModuleName.size() = " + allModuleName.size());

        JSONObject accounts = crmApiUtil.getDataById("Accounts", "203201000001727139");
        //System.out.println("accounts.toJSONString() = " + accounts.toJSONString());


        JSONObject contact = new JSONObject();
        //contact.put("Last_Name","张 三");
        contact.put("Last_Name","李  四");
        List<JSONObject> insertList = new ArrayList<>();
        insertList.add(contact);
        crmApiUtil.batchInsertDataByList(insertList,"Contacts");


    }
}
